package edu.spec.teacher.service.impl;

import edu.spec.basic.dao.iface.IUserDao;
import edu.spec.basic.model.User;
import edu.spec.teacher.dao.iface.ISignInDao;
import edu.spec.teacher.dao.iface.IUserSignInDao;
import edu.spec.teacher.model.SignIn;
import edu.spec.teacher.model.UserSignIn;
import edu.spec.teacher.service.iface.ISignInService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Author       : MadFrog
 * Date         : 2018/10/9 19:01
 * Description  :
 */
@Service
public class SignInService implements ISignInService {

    @Autowired
    private ISignInDao signInDao;
    @Autowired
    private IUserSignInDao userSignInDao;
    @Autowired
    private IUserDao userDao;

    @Override
    public void add(SignIn signIn) {
        signIn = signInDao.add(signIn);
        List<User> userList = userDao.listAll();
        for (User u : userList){
            userSignInDao.add(new UserSignIn(u, signIn));
        }
    }
}
